<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css"></style>
</head>
<body>
    <h1>cookie</h1>
    <hr>

    <script>
    // JS 获取 cookie
    document.write('读取cookie: ' + document.cookie + '<br>');

    // JS 设置 cookie
    document.cookie = 'sex=11';
    document.write('读取cookie: ' + document.cookie + '<br>');


    // 指定生效路径 /
    document.cookie = 'sex2=6; path = /';
    document.write('读取cookie: ' + document.cookie + '<br>');

    // 设置 cookie 的有效期
    var d = new Date(); // 获取时间对象
    d.setTime(d.getTime() + 3600*1000); // 未来1小时
    document.cookie = 'sex3 = 999; path = /; expires = ' + d.toUTCString();

    // 删除cookie....

    
    </script>



</body>
</html>



